<div class="box">
    <div class="box-header">
        <h3 class="box-title"></h3> 
        <div class="pull-right">
            <div class="form-inline pull-right">
                <form action="{{admin_url('crm_chengjiao')}}/chengjiao" id="chengjiao" method="post">
                    <fieldset>
                        {{ csrf_field() }}
                        <div class="input-group input-group-sm">
                            <span class="input-group-addon"><strong>部门</strong></span>
                            <select class="form-control bumen" style="width: 100%;" name="bumen" id="bumen">
                            <option value>选择</option>
                            @foreach($list['bumen'] as $vo)
                            <option value="{{$vo->id}}">{{$vo->name}}</option>
                            @endforeach
                            </select>
                        </div>
                        <div class="input-group input-group-sm">
                            <span class="input-group-addon"><strong>员工</strong></span>
                            <select class="form-control yuangong" style="width: 100%;" name="yuangong" id="yuangong">
                            <option value>选择</option>
                            
                            @foreach($list['yuangong'] as $vo)
                            <option value="{{$vo->id}}">{{$vo->username}}</option>
                            @endforeach
                        </select>
                        </div>
                        <div class="input-group input-group-sm">
                            <span class="input-group-addon"><strong>下单日期</strong></span>
                            <input type="text" class="form-control" id="order_lvyoudate_start" placeholder="下单日期" name="order_lvyoudate[start]" value="">
                            <span class="input-group-addon" style="border-left: 0; border-right: 0;">-</span>
                            <input type="text" class="form-control" id="order_lvyoudate_end" placeholder="下单日期" name="order_lvyoudate[end]" value="">
                        </div>已升级到最新版
                        <div class="btn-group btn-group-sm">
                            <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button>
                            <a href="http://crm.com/admin/crm_chengjiao?_pjax=%23pjax-container" class="btn btn-warning"><i class="fa fa-undo"></i></a>
                        </div>
                    </fieldset>
                </form>
            </div>
            
        </div>
    </div>
    <!-- /.box-header -->
    <div class="box-body table-responsive no-padding">
        <table id="table" class="table table-hover">
            <tbody>
                <tr>
                    <th>客户</th>
                    <th>电话</th>
                    <th>线路名称</th>
                    <th>员工姓名</th>
                    <th>应收金额</th>
                    <th>实收金额</th>
                    <th>请款金额</th>
                    <th>预估毛利</th>
                    <th>发团日期</th>
                    <th>下单日期</th>
                </tr>
                @foreach($list['list'] as $value)
                <tr>
                @foreach($list['customer'] as $jk)
                    @if($value->deal_customer_id==$jk->id)
                        <td>{{$jk->customer_name}}</td>
                        <td>{{$jk->customer_phone}}</td>      
                    @endif
                @endforeach
                @foreach($list['order'] as $order)
                    @if($value->deal_orderid==$order->id)
                    <td>{{$order->order_xianlu}}</td>
                    @endif
                @endforeach
                    <td>{{$value->deal_yuangong}}</td>
                    <td>{{$value->deal_yshoukuan}}</td>
                    <td>{{$value->deal_sshoukuan}}</td>
                    <td>{{$value->deal_sdakuan}}</td>
                    <td>{{$value->deal_yglirun}}</td>
                    <td>{{$value->deal_ftdate}}</td>
                    <td>{{$value->deal_dealdate}}</td>
                </tr>
                @endforeach
                <tr>
                    <th>总计</th>
                    <th></th>
                    <th></th>
                    <th>未收款：{{$list['yshoukuan']}}</th>
                    <th></th>
                    <th>未付款：{{$list['dakuan']}}</th>
                    <th></th>
                    <th>预估毛利：{{$list['ygzongji']}}</th>
                    <th></th>
                    <th></th>
                    <!-- <th>操作</th> -->
                </tr>
            </tbody>
        </table>
    </div>
    <div class="box-footer clearfix">
        <ul class="pagination pagination-sm no-margin pull-right">
            {{ $list['list']->links() }}
        </ul>
    </div>
</div>
<script>

    $(function () {
        $('#order_lvyoudate_start').datetimepicker({"format":"YYYY-MM-DD HH:mm:ss","locale":"zh_CN"});
        $('#order_lvyoudate_end').datetimepicker({"format":"YYYY-MM-DD HH:mm:ss","locale":"zh_CN","useCurrent":false});
        $("#order_lvyoudate_start").on("dp.change", function (e) {
        $('#order_lvyoudate_end').data("DateTimePicker").minDate(e.date);
        });
        $("#order_lvyoudate_end").on("dp.change", function (e) {
            $('#order_lvyoudate_start').data("DateTimePicker").maxDate(e.date);
        });
        $(".bumen").change(function(){
            var id=$(".bumen option:selected").val();
            $.ajax({
                url: "/admin/gdindex/ajax13",
                type: "get",
                dataType: "json",
                data: {'v': id},
                success:function(data){
                    var hh="<option value>请-选-择<\/option>";
                    for(var i=0;i<data.length;i++){
                        hh +="<option value="
                        hh +=data[i].id
                        hh +=" >"
                        hh +=data[i].username
                        hh +="<\/option>";
                       
                    }
                    $(".yuangong").html(hh);
                }
            }); 
        })
        $("#dianji").click(function(){
            $.ajax({
                url: "/admin/gdindex/ajax14",
                type: "get",
                dataType: "json",
                data: {'bumen':$("#bumen").val(),'yuangong':$("#yuangong").val(),'kaishi':$("#order_lvyoudate_start").val(),'jieshu':$("#order_lvyoudate_end").val()},
                success:function(data){
                    var hh="tr";
                    for(var i=0;i<data.list.length;i++){
                        hh +="<tr>"
                        hh +="</tr>";
                    }
                    alert(data.list.current_page);
                    $("#table").html("<tr><th>客户</th><th>电话</th><th>线路名称</th><th>员工姓名</th><th>应收金额</th><th>实收金额</th><th>请款金额</th><th>预估毛利</th><th>发团日期</th><th>下单日期</th></tr><tr><th>总计</th><th></th><th></th><th>未收款："+data.yshoukuan+"</th><th></th><th>未付款："+data.dakuan+"</th><th></th><th>预估毛利："+data.ygzongji+"</th><th></th><th></th></tr>");
                }
            });
        });
    })
</script>